package com.hnjd.service.imp;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hnjd.entity.Goods;
import com.hnjd.entity.Types;
import com.hnjd.dao.GoodsMapper;
import com.hnjd.dao.TypeMapper;
import com.hnjd.service.IgoodsService;
import com.hnjd.util.PageUtil;
@Service
public class GoodsServiceImpl implements IgoodsService {

	@Autowired
	private GoodsMapper goodsMapper;
	
	@Autowired
	private TypeMapper tm;
	 
	@Override
	public List<Goods> findAllGoods(PageUtil page,Integer type) {
		// TODO Auto-generated method stub
		return goodsMapper.findAllGoods(page,type);
	}

	@Override
	public void goodDelete(Integer id) {
		// TODO Auto-generated method stub
		goodsMapper.goodDelete(id);
	}

	@Override
	public Map<String, Object> findGoodById(Integer id) {
		Map<String, Object> map=new HashMap<String, Object>();
		Goods good = goodsMapper.findGoodById(id);
		List<Types> list = tm.findAllTypes();
		map.put("good", good);
		map.put("list", list);
		// TODO Auto-generated method stub
		return map;
	}

	@Override
	public void updateGoods(Goods good) {
		// TODO Auto-generated method stub
		goodsMapper.updateGoods(good);
		
	}

	

	@Override
	public void goodAdd(Goods good) {
		// TODO Auto-generated method stub
		goodsMapper.goodAdd(good);
	}

}
